# This file is intended to be a final submission. python tester.py Player.py
# should work at all times. If it does not, there is a bug.
# If you're just trying to test a solution, scroll down to the Player
# class.

# This file is intended to be in the same format as a valid solution, so
# that users can edit their solution into Player and then submit just this
# file to the contest. If you see any reason this would not work, please submit
# an Issue to https://github.com/ChadAMiller/hungergames/issues or email me.

# You can see more sample player classes in bots.py

class BasePlayer(object):
    '''
    Base class so I don't have to repeat bookkeeping stuff.
    Do not edit unless you're working on the simulation.
    '''
    
    def __str__(self):
        try:
            return self.name
        except AttributeError:
            # Fall back on Python default
            return super(BasePlayer, self).__repr__()
    
    def hunt_choices(*args, **kwargs):
        raise NotImplementedError("You must define a strategy!")
        
    def hunt_outcomes(*args, **kwargs):
        pass
        
    def round_end(*args, **kwargs):
        pass


class Player(BasePlayer):
    '''
    Your strategy starts here.
    '''
    def __init__(self, number=None):
        self.name = "User Player"
        if number:
            self.name = self.name + " %d" % number
    
    def hunt_choices(
                    self,
                    round_number,
                    current_food,
                    current_reputation,
                    m,
                    player_reputations,
                    ):
        '''Required function defined in the rules'''
        
        if round_number == 1:
            print "deciding based on m"
            p = len(player_reputations) + 1
            games = p * (p - 1)
            factor = int(games / m)
            if factor < 2: factor = 2
            if factor > 4: factor = 5
            r = []
            for i in range(len(player_reputations)):
                if (i % factor) == 0:
                    r.append('s')
                else:
                    r.append('h')
            return r

        retArray = []
        avg = sum(player_reputations) / len(player_reputations)
        for value in player_reputations:
            if value < .25:
                retArray.append('s')
            elif value > .85:
                retArray.append('s')
            else:
#print "deciding based on m"
                p = len(player_reputations) + 1
                games = p * (p - 1)
                factor = float(m) / games
                decision = ""
                if factor > .2 and factor < .6:
                    retArray.append('h')
                    decision = "hunt"
                else:
                    retArray.append('s')
                    decision = "slack"
#print "m: %d, #games: %d, factor: %s, decision: %s" % (
#m,
#games,
#factor,
#decision
#)
            
        return retArray
        

    def hunt_outcomes(self, food_earnings):
        '''Required function defined in the rules'''
        pass
        

    def round_end(self, award, m, number_hunters):
        '''Required function defined in the rules'''
        pass
        
